#include<iostream>
#include<cstdio>
#define R register
using namespace std;
const int N=1000005;
int n,q,lx,x,y,ans[N],a[N],b[N],bh[N];
void pai(int i,int j)
{
	R int l=i,r=j,mid=b[(i+j)>>1],mid2=bh[(i+j)>>1];
	while (i<j)
	{
		while (b[i]<mid||b[i]==mid&&bh[i]<mid2) ++i;
		while (b[j]>mid||b[j]==mid&&bh[j]>mid2) --j;
		if (i<=j)
		{
			swap(b[i],b[j]);swap(bh[i],bh[j]);
			++i;--j;
		}
	}
	if (i<r) pai(i,r);
	if (l<j) pai(l,j);
}
int main()
{
	freopen("sort.in","r",stdin);freopen("sort.out","w",stdout);
	scanf("%d%d",&n,&q);
	for (R int i=1;i<=n;++i)
	{
		scanf("%d",&a[i]);
		b[i]=a[i];bh[i]=i;
	}
	pai(1,n);
	for (R int i=1;i<=n;++i)
		ans[bh[i]]=i;
	while (q--)
	{
		scanf("%d",&lx);
		if (lx==1)
		{
			scanf("%d%d",&x,&y);
			ans[x]=1;
			for (R int i=1;i<=x-1;++i)
			{
				if (a[i]<=y) ++ans[x];
				if (a[i]<=a[x]&&a[i]>y) ++ans[i];
				if (a[i]>a[x]&&a[i]<=y) --ans[i];
			}
			for (R int i=x+1;i<=n;++i)
			{
				if (a[i]<y) ++ans[x];
				if (a[i]<a[x]&&a[i]>=y) ++ans[i];
				if (a[i]>=a[x]&&a[i]<y) --ans[i];
			}
			a[x]=y;
		}
		else
		{
			scanf("%d",&x);
			printf("%d\n",ans[x]);
		}
	}
	return 0;
}
